﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;

using Frame.Lib.Utilities;
using Frame.Lib.Common;

namespace Frame.Web.Common.Dict
{
    public partial class Item : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlGenericControl body = (HtmlGenericControl)this.Master.Page.Form.FindControl("body");
            body.Attributes.Add("class", "left_body_bg");
            BindTree();
            JSUtil.SetDivHeight("tree", 30);
        }

        private void BindTree()
        {

            List<EnumInfo> list = new List<EnumInfo>();

            string[] dicts = AppSetting.DictItem.Split(';');
            foreach (string str in dicts)
            {
                if (!string.IsNullOrEmpty(str))
                {
                    Type type = Type.GetType(str);
                    if (type != null)
                    {
                        list.AddRange(ConvertUtil.ConvertEnum(type));
                    }
                }
            }
            tv.CssClass = "treeview";
            string navigateUrl = "List.aspx?ItemID=";
            foreach (EnumInfo info in list)
            {
                TreeNode node = new TreeNode();
                node.Text = info.Name;
                node.NavigateUrl = navigateUrl + StrUtil.EncryptUrl(info.ID) + "&ItemName=" + Server.UrlEncode(info.Name);
                tv.Nodes.Add(node);
            }
            
        }
    }
}
